package com.gy.smart.life.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.amap.api.maps2d.model.BitmapDescriptorFactory;
import com.gy.smart.R;
import com.gy.smart.life.bean.LifeListBean;
import com.gy.smart.util.map.MapBaseDrawable;

/**
 * Created by 高岳 on 2017/1/11.
 * Describe:
 */
public class MapMarkerView  extends MapBaseDrawable<LifeListBean> {

    private Context context;
    private View mRoot;
    private LayoutInflater inflater;
    private ImageView imgMarker;
    private int[] normalImgs = new int[]{R.mipmap.ic_map_marker1,R.mipmap.ic_map_marker2,R.mipmap.ic_map_marker3,
            R.mipmap.ic_map_marker4,R.mipmap.ic_map_marker5,R.mipmap.ic_map_marker6,R.mipmap.ic_map_marker7,
            R.mipmap.ic_map_marker8};
    private int[] selectImgs = new int[]{R.mipmap.ic_map_marker_select1,R.mipmap.ic_map_marker_select2,
            R.mipmap.ic_map_marker_select3,R.mipmap.ic_map_marker_select4,R.mipmap.ic_map_marker_select5,
            R.mipmap.ic_map_marker_select6,R.mipmap.ic_map_marker_select7,R.mipmap.ic_map_marker_select8};

    public MapMarkerView(Context context){
        this.context = context;
        inflater = LayoutInflater.from(context);
        mRoot = inflater.inflate(R.layout.view_life_map_marker,null);
        imgMarker = (ImageView) mRoot.findViewById(R.id.view_life_map_marker);
    }

    @Override
    public Bitmap createMarker(LifeListBean bean) {
        mRoot = inflater.inflate(R.layout.view_life_map_marker,null);
        imgMarker = (ImageView) mRoot.findViewById(R.id.view_life_map_marker);
        if(bean.isSelect == 0){
            imgMarker.setImageResource(normalImgs[Integer.valueOf(bean.lc_id) - 1]);
        } else {
            imgMarker.setImageResource(selectImgs[Integer.valueOf(bean.lc_id) - 1]);
        }
        Bitmap bitmap = BitmapDescriptorFactory.fromView(mRoot).getBitmap();
        return bitmap;
    }
}
